package org.ala.tcp_feign_common.msg.biz;

import org.ala.tcp_feign_common.enums.TcpFeignMessageTypeEnums;
import org.ala.tcp_feign_common.msg.AbstractByteMessage;


/**
 * 业务消息
 * 
 * [0x05 | 消息总长(4字节) | 消息id(8字节) | 发送消息时间戳(8子节) | 消息体（不定长]
 * 
 * 消息id：会贯穿 biz -> bizAck，bizResp -> bizResp流程 
 * 
 * @author 骆毅(ala)
 * @date 2024年4月19日
 */
public class BizByteMessage extends AbstractByteMessage {
	private static final long serialVersionUID = 1L;

	
	/**
	 * 消息id
	 */
	protected long msgId;
	/**
	 * 发送消息时间戳
	 */
	protected long timestamp;
	/**
	 * 消息体
	 */
	protected byte[] body;
	
	
	public static BizByteMessage build(long msgId, byte[] body) {
		BizByteMessage msg = new BizByteMessage();
		msg.setMsgId(msgId);
		msg.setBody(body);
		msg.setTimestamp(System.currentTimeMillis());
		return msg;
	}
	
	
	@Override
	public TcpFeignMessageTypeEnums type() {
		return TcpFeignMessageTypeEnums.BIZ;
	}


	public long getMsgId() {
		return msgId;
	}


	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}


	public long getTimestamp() {
		return timestamp;
	}


	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}


	public byte[] getBody() {
		return body;
	}


	public void setBody(byte[] body) {
		this.body = body;
	}

}
